package com.cn.gxa.redis.controller;

import com.cn.gxa.model.ResultData;
import com.cn.gxa.redis.bean.User;
import com.cn.gxa.redis.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping("/login")
    public ResultData  login(String name,String password){
        //存入redis中
      String  token=  userService.login(name,password);
      return   ResultData.ok().data(token);
    }

    @RequestMapping("/findAll")
    public  ResultData findAll(){
        List<User>  list=  userService.findAll();
        return   ResultData.ok().data(list);
    }

}
